<?php
session_start();
$action = $_GET['action'];
$domain = $_POST['domain'];
if ($action == "add") {
  mysql_connect("localhost", "", "");
  mysql_query("USE stats_syslog");
  $query = mysql_query("INSERT INTO domains VALUES ('$domain')");
  mysql_query($query);
  mysql_close();
  echo "<html>\n";
  echo "<head>\n";
  echo "<title>Domain '$domain' Added</title>\n";
  echo "</head>\n";
  echo "<body>\n";
  echo "Domain '$domain' Added\n";
  echo "<FORM method=post action=domain_edit.php>";
  echo "<INPUT TYPE=SUBMIT VALUE=\"OK\">";
  echo "</FORM>";
  echo "</body>";
  echo "</html>";
  exit();
  }
elseif ($action == "delete") {
  mysql_connect("localhost", "", "");
  mysql_query("USE stats_syslog");
  $query = mysql_query("DELETE FROM domains WHERE domain='$domain'");
  mysql_close();
  echo "<html>\n";
  echo "<head>\n";
  echo "<title>Domain '$domain' Deleted</title>\n";
  echo "</head>\n";
  echo "<body>\n";
  echo "Domain '$domain' Deleted\n";
  echo "<FORM method=post action=domain_edit.php>";
  echo "<INPUT TYPE=SUBMIT VALUE=\"OK\">";
  echo "</FORM>";
  echo "</body>";
  echo "</html>";
  exit();
  }

echo "<html>\n";
echo "<head>\n";
echo "<title>Edit List of Domains</title>\n";
echo "</head>\n";
echo "<body>\n";
echo "<b>Edit List of Domains</b>\n";

echo "<BR><BR><b>Add Domain:</b>";
echo "<FORM method=post action=domain_edit.php?action=add>";
echo "<INPUT type=text name=domain length=100 maxlength=100 onBlur=\"submit()\">";
echo "</FORM>";

echo "<BR><BR><b>Delete Domain:</b>";
echo "<FORM method=post action=domain_edit.php?action=delete>";
echo "<INPUT type=text name=domain length=100 maxlength=100 onBlur=\"submit()\">";
echo "</FORM>";

echo "</body>\n";
echo "</html>\n";
?>
